<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>编辑提问问题</title>


<link href="${base}/resources/admin/css/amazeui.css" rel="stylesheet" type="text/css" />
<link href="${base}/resources/admin/css/common.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .text-line {
            line-height: 20px;
        }
        .question_image {
            cursor: pointer;
        }
    </style>
</head>
<body>
	<div class="path">
		<a href="${base}/asl-admin/common/index.htm">${message("admin.path.index")}</a> &raquo; 编辑提问问题
	</div>
	<form id="inputForm" action="update.htm" method="post" enctype="multipart/form-data">
		<input type="hidden" name="id" value="${question.id}" />
        <ul id="tab" class="tab">
            <li>
                <input type="button" value="基本问题" />
            </li>
            <li>
                <input type="button" value="问题图片" />
            </li>
        </ul>
		<table class="input tabContent">
            <tr>
                <th>
                    <span class="requiredField"></span>编号:
                </th>
                <td>
                [#if question.sn??]
                        ${question.sn}
                    [/#if]
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>提问者:
                </th>
                <td>
                    [#if question.member??]
                        ${question.member.username}
                    [/#if]
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField"></span>被提问老师:
                </th>
                <td>
                    [#if question.teacher??]
                        ${question.teacher.username}
                    [/#if]
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>问题标签:
                </th>
                <td>
                    <label><input type="radio" name="payType" value="风水" [#if question.payType=="风水"] checked[/#if] />风水 </label>
                    <label><input type="radio" name="payType" value="婚恋感情" [#if question.payType=="婚恋感情"] checked[/#if]  />婚恋感情 </label>
                    <label><input type="radio" name="payType" value="事业财运" [#if question.payType=="事业财运"] checked[/#if]  />事业财运 </label>
                    <label><input type="radio" name="payType" value="其他" [#if question.payType=="其他"] checked[/#if]  />其他 </label>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>提问价格:
                </th>
                <td>
                    <input type="text" name="payPrice" class="text" maxlength="200" value="${question.payPrice}" />
                </td>
            </tr>
            <tr>
                <th>
                    是否分享:
                </th>
                <td>
                    <label><input type="radio" name="isShare" value="true"  [#if question.isShare==true] checked[/#if] />是</label>
                    <label><input type="radio" name="isShare" value="false" [#if question.isShare==false] checked[/#if] />否</label>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>姓名:
                </th>
                <td>
                    <input type="text" name="name" class="text" maxlength="200" value="${question.name}" />
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>性别:
                </th>
                <td>
                    <label><input type="radio" name="gender" value="male"  [#if question.gender=="male"] checked[/#if] />男</label>
                    <label><input type="radio" name="gender" value="female" [#if question.gender=="female"] checked[/#if]  />女</label>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>出生日期:
                </th>
                <td>
                    <input type="text" id="birth" name="birth" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" value="${question.birth?string("yyyy-MM-dd")}" />
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>出生时辰:
                </th>
                <td>
                    <input type="text" name="birthHour" class="text" maxlength="200" value="${question.birthHour}" />
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>标题:
                </th>
                <td>
                    <input type="text" name="title" class="text" maxlength="800" style="width: 500px" value="${question.title}"/>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>内容:
                </th>
                <td>
                    <textarea name="content" class="text text-line"  style="width: 400px;height: 200px">${question.content}</textarea>
                </td>
            </tr>
            <tr>
                <th>
                    <span class="requiredField">*</span>邮箱:
                </th>
                <td>
                    <input type="text" name="email" class="text" maxlength="200" value="${question.email}" />
                </td>
            </tr>
            <tr>
                <th>
                    支付状态:
                </th>
                <td>
                    <label><input type="radio" name="paymentStatus" value="paid"  [#if question.paymentStatus=="paid"] checked[/#if] />是</label>
                    <label><input type="radio" name="paymentStatus" value="unpaid" [#if question.paymentStatus=="unpaid"] checked[/#if] />否</label>
                </td>
            </tr>
            <tr>
                <th>
                    回答状态:
                </th>
                <td>
                    <span [#if question.answerStatus == "yes"]class="am-badge am-badge-success am-radius"[#else]class="am-badge am-badge-danger am-radius"[/#if]>${(question.answerStatus.toValue())!""}</span>
                </td>
            </tr>
            <tr>
                <th>
                   	创建时间:
                </th>
                <td>
					${question.createDate?string("yyyy-MM-dd HH:mm:ss")}
                </td>
            </tr>
		</table>
        <table id="questionImageTable" class="input tabContent">
            <tr>
                <td colspan="4">
                    <a href="javascript:;" id="addQuestionImage"
                       class="button">${message("admin.product.addProductImage")}</a>
                </td>
            </tr>
            <tr class="title">
                <td>
				${message("ProductImage.file")}
                </td>
                <th>
                    预览
                </th>
                <td>
				${message("admin.common.delete")}
                </td>
            </tr>
			[#list question.images as questionImage]
				<tr>
					<td>
						<input type="file" name="questionImage"
							   class="productImageFile ignore imgChange"/>
						<span class="tips">建议上传的图片的宽高比例为1:1</span>
					</td>
					<td>
						<div class="photoChange">
							<img src="${questionImage}" alt="" class="question_image"/>
							<input type="hidden" name="images[${questionImage_index}]" value="${questionImage}">
						</div>
					</td>
					<td>
						<a href="javascript:;" class="deleteProductImage"><i
								class="iconfont icon-shequshanchu del-icon"></i></a>
					</td>
				</tr>
			[/#list]
		</table>
        <table class="input">
			<tr>
				<th>
					&nbsp;
				</th>
				<td>
					<input type="submit" class="button" value="${message("admin.common.submit")}" />
					<input type="button" class="button" value="${message("admin.common.back")}" onclick="location.href='list.htm'" />
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.tools.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="${base}/resources/admin/editor/kindeditor.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/common.js"></script>
<script type="text/javascript" src="${base}/resources/admin/js/input.js"></script>
<script type="text/javascript" src="${base}/resources/admin/datePicker/WdatePicker.js"></script>

<script type="text/javascript">
    $().ready(function() {

        var $inputForm = $("#inputForm");
        var $browserButton = $("#browserButton");

        var $questionImageTable = $("#questionImageTable");
        var $addQuestionImage = $("#addQuestionImage");
        var $deleteProductImage = $("a.deleteProductImage");
        var questionImageIndex = ${(question.images?size)!"0"};

        $(".question_image").on("click", function () {
            window.open($(this).attr("src"));
        })        
        
    [@flash_message /]

        $browserButton.browser();

        // 表单验证
        $inputForm.validate({
            rules: {
                payType: "required",
                payPrice: "required",
                isShare: "required",
                name:"required",
                gender: "required",
                birth:"required",
                birthHour:"required",
                title:"required",
                email: {
                    required: true,
                    email: true
                },
                content:"required"
            }
        });

        // 增加认证图片
        $addQuestionImage.click(function () {
        [@compress single_line = true]
            var trHtml =
                    '<tr>
                    <td>
                    <input type="file" name="questionImage" class="productImageFile imgChange"\/>
        <\/td>
        <td>
        <div class="photoChange"><\/div>
        <\/td>
        <td>
        <a href="javascript:;" class="deleteProductImage"><i class="iconfont icon-shequshanchu del-icon"><\/i><\/a>
        <\/td>
        <\/tr>';
        [/@compress]
            $questionImageTable.append(trHtml);
            questionImageIndex++;

            $('.imgChange').change(function () {
                var file = this.files[0];
                var r = new FileReader();
                var t = $(this);
                r.readAsDataURL(file);
                $(r).load(function () {
                    t.parent().next().children('.photoChange').html('<img src="' + this.result + '" alt=""  />');
                })
            });
        });

        $('.imgChange').change(function () {
            var file = this.files[0];
            var r = new FileReader();
            var t = $(this);
            r.readAsDataURL(file);
            $(r).load(function () {
                t.parent().next().children('.photoChange').html('<img src="' + this.result + '" alt=""  />');
            })
        });


        // 删除商品图片
        $deleteProductImage.live("click", function () {
            var $this = $(this);
            $.dialog({
                type: "warn",
                content: "${message("admin.dialog.deleteConfirm")}",
                onOk: function () {
                    $this.closest("tr").remove();
                }
            }, 260, 180);
        });

    });
</script>
</html>
